package genedit.model.graph.classModel;

import java.io.Serializable;

public class GAttribute implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 3914177701031299686L;

	public enum VisibilityType {
		priv, prot, publ
	};

	private String name;
	private String type;
	private String preDef;
	private VisibilityType visibility;
	private boolean getAttribute;
	private boolean setAttribute;

	public VisibilityType getVisibilityType() {
	return visibility;
	}
	
	public void setVisibilityType(VisibilityType visibility) {
		this.visibility = visibility;
		}
	
	public String getPreDef() {
		return preDef;
	}
	
	public void setPreDef(String preDef) {
		this.preDef = preDef;
	}
	
	public void setVisibilityType(String visi) {
	if (visi.equals("private")) {
		this.visibility = VisibilityType.priv;
	} else if(visi.equals("protected")) {
		this.visibility = VisibilityType.prot;
	} else {
		this.visibility = VisibilityType.publ;
	}
	}
	
	public String getVisibility() {
		if (visibility == VisibilityType.priv) {
			return "private";
		} else if (visibility == VisibilityType.prot) {
			return "protected";
		} else {
			return "public";
		}
	}

	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public GAttribute(){
		this.name = "";
		this.type = "";
		this.preDef = "";
		this.visibility = VisibilityType.priv;
		getAttribute = false;
		setAttribute = false;
	}
	
	public GAttribute(String name, String type, String visi, String predef) {
		this.name = name;
		this.type = type;
		this.preDef = predef;
		if (visi.equals("private")) {
			this.visibility = VisibilityType.priv;
		} else if(visi.equals("protected")) {
			this.visibility = VisibilityType.prot;
		} else {
			this.visibility = VisibilityType.publ;
		}
		getAttribute = false;
		setAttribute = false;
	}

	@Override
	public String toString() {
		String retVal;
		if (visibility == VisibilityType.priv) {
			retVal = "- ";
		} else if (visibility == VisibilityType.prot) {
			retVal = "# ";
		} else {
			retVal = "+ ";
		}
		if(preDef.equals(""))
		return retVal + name + " : " + type;
		return retVal + name+" = "+ preDef + " : " + type;
	}

	public boolean isGetAttribute() {
		return getAttribute;
	}

	public void setGetAttribute(boolean getAttribute) {
		this.getAttribute = getAttribute;
	}

	public boolean isSetAttribute() {
		return setAttribute;
	}

	public void setSetAttribute(boolean setAttribute) {
		this.setAttribute = setAttribute;
	}
}
